package cn.kgc.springboot.controller;

import cn.kgc.springboot.entity.Student;
import cn.kgc.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author mosin
 * date 2021/12/11
 * @version 1.0
 */
@Controller
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/h1")
    public String h1(){
        return "hello";
    }


    @RequestMapping("/findall")
    public String h2(Model model){
        List<Student> all = studentService.findAll();
        model.addAttribute("students", all);
        return "hello";
    }

}
